<div class="boxed">
    <div id="content-container">
        <div id="page-title">
            <h1 class="page-header text-overflow">Data Tables</h1>
            <div class="searchbox">
                <div class="input-group custom-search-form">
                    <input type="text" class="form-control" placeholder="Search..">
                    <span class="input-group-btn">
                        <button class="text-muted" type="button"><i class="demo-pli-magnifi-glass"></i></button>
                    </span>
                </div>
            </div>
        </div>
        <ol class="breadcrumb">
            <li><a href="{:url('Admin/Index/index')}">首页</a></li>
            <li>陪玩控制台</li>
            <li class="active">用户管理</li>
        </ol>
        <div id="page-content">
            <div class="panel">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        <button class="btn btn-primary" onclick="editorBanner()">
                            修改Banner
                        </button>
                    </h3>
                </div>
                <div class="panel-body">
                    <table id="demo-dt-basic" class="table table-striped table-bordered" cellspacing="0" width="100%">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>图片</th>
                            <th>URL</th>
                            <th>描述</th>
                            <th>状态</th>
                            <th>排序</th>
                        </tr>
                        </thead>
                        <tbody>
                        {foreach name="banner" id="v"}
                        <tr>
                            <td>{$v['id']}</td>
                            <td style="cursor:pointer" onclick="rule.showUserSet('{$v.img}')">
                                <img src="{$v['img']}" width="30">
                            </td>
                            <td>
                                <span class="btn btn-rounded btn-labeled">{$v['url']}</span>
                            </td>
                            <td>{$v['desc']}</td>
                            <td align="center">
                                {eq name="$v.status" value="1"}
                                <button class="btn btn-xs btn-success">显示</button>
                                {else/}
                                <button class="btn btn-xs btn-default">未显示</button>
                                {/eq}
                            </td>
                            <td>{$v['index']}</td>
                        </tr>
                        {/foreach}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 修改菜单模态框结束 -->
<script type="text/javascript">
    var rule = {
        add:function () {
            this.open('#thinkright-add');
        },
        edit:function (obj) {
            setTimeout(function () {
                $("input[name='id']").val(obj.id);
                $("input[name='title']").val(obj.title);
                $("input[name='name']").val(obj.name);
                $("input[name='description']").val(obj.description);
                $("input[name='editor']").val(obj.id);
                $("input[name='icon']").val(obj.icon);
                $('.status'+obj.status).attr('checked',true).siblings('input').remove('checked');
                $('.func'+obj.func).attr('checked',true).siblings('input').remove('checked');
                $('.pid_'+obj.pid).attr('selected','selected').siblings('option').remove('selected');
                $('.submitDoc').text('编辑表单');
                $('#myModalLabel').text('编辑菜单')
            },500);
            this.open('#thinkright-add');
        },
        open:function (name) {
            layer.open({
                type: 1,
                shade: 0.6,
                title: false, //不显示标题
                area: ['600px', '680px'], //宽高
                scrollbar: false,
                content:$(name).html(),
                cancel: function(){}
            });
        },
        child:function (obj) {
            var ruleId=$(obj).attr('ruleId');
            $("input[name='pid']").val(ruleId);
            this.add();
        },
        submit:function () {
            form.ajax('#ruleAdd',function (res) {
                layer.msg(res.msg,function () {
                    if(res.code > 0){
                        layer.closeAll();
                        location.reload();
                    }
                })
            })
        },
        del:function (obj) {
            layer.confirm('你确定要删除吗?', {
                btn: ['删除','取消'] //按钮
            }, function(){
                $.post(obj.attr('href'), function(data) {
                    layer.msg(data.msg, {icon: 1},function () {
                        if(data.code > 0){
                            layer.closeAll();
                            location.reload();
                        }
                    });
                });
            }, function(){
            });
        },
        showUserSet:function (img) {
            if(!img){
                layer.msg('暂无设置...');
                return false;
            }
            layer.open({
                type: 1,
                shade: 0.6,
                title: false, //不显示标题
                scrollbar: false,
                content:"<img style='width:100%;height:100%;max-width:480px;' src='"+img+"'></img>",
                cancel: function(){}
            });
        },
        confim:function (status,tysg) {
            layer.confirm('确定要禁封吗？', {
                btn: ['封掉','算了'] //按钮
            }, function(){
                $.post('/index.php/Admin/user/userEdit',{
                    value:tysg,
                    name:'user_status',
                    uid:status
                }, function(data) {
                    layer.msg(data.msg, {icon: 1});
                    if(data.code > 0){
                        location.reload();
                    }
                });
            }, function(){});
        }
    };
    function editorBanner() {
        localStorage.setItem('editor','{$bannerJson}');
        layerBox.show('在线代码编辑器',['60%', '70%'],'/index.php/Admin/editor?ename=editor');
    }
    function saveEditor(value) {
        console.log(value);
        $.post('/index.php/Admin/play/banner?act=add', {value:value}, function(data) {
            layer.msg(data.msg,{time:3000},function () {
                if(data.code > 0){
                    EditorClose();
                    setTimeout(function () {
                        location.reload();
                    },200)
                }
            });
        });
    }
    function EditorClose() {
        layer.closeAll();
    }
</script>